<%-- 
    Document   : detailpdma
    Created on : Nov 29, 2011, 5:42:12 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.*, java.text.NumberFormat,Beans.ThamSoHT,Models.ThamSoHT_Model, Models.MonAn_Model, Models.PhieuDatMA_Model, Models.TienTe_Model, Models.DonViTinh_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127 || keypressed == 44 || keypressed == 46 )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'customermsg', 'moneyofcustomermsg', 'moneyback', 'moneyofcustomer', 'checksubmitmsg', 'printbill', 'printorderbill', 'foodname', 'price', 'quantity', 'unit', 'orderbillinfo', 'promotion', 'customerid', 'timehistory', 'tablename', 'rightmsg', 'nameofcustomer', 'orderbillid', 'numberofcustomer', 'servicecharge', 'notice', 'total', 'temptotal', 'reduction', 'areaname' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.


            String areaname = mdsts[0].getTenTS();
            String checksubmit = mdsts[1].getTenTS();
            String customerid = mdsts[2].getTenTS();
            String customermsg = mdsts[3].getTenTS();
            String foodname = mdsts[4].getTenTS();
            String moneyback = mdsts[5].getTenTS();
            String moneyofcustomer = mdsts[6].getTenTS();
            String moneyofcustomermsg = mdsts[7].getTenTS();
            String nameofcustomer = mdsts[8].getTenTS();
            String notice = mdsts[9].getTenTS();
            String numberofcustomer = mdsts[10].getTenTS();
            String orderbillid = mdsts[11].getTenTS();
            String orderbillinfo = mdsts[12].getTenTS();
            String price = mdsts[13].getTenTS();
            String printbill = mdsts[14].getTenTS();
            String printorderbill = mdsts[15].getTenTS();
            String promotion = mdsts[16].getTenTS();
            String quantity = mdsts[17].getTenTS();
            String reduction = mdsts[18].getTenTS();
            String rightmsg = mdsts[19].getTenTS();
            String servicecharge = mdsts[20].getTenTS();
            String tablename = mdsts[21].getTenTS();
            String temptotal = mdsts[22].getTenTS();
            String timehistory = mdsts[23].getTenTS();
            String total = mdsts[24].getTenTS();
            String unit = mdsts[25].getTenTS();

            String msgright = notice + "/" + rightmsg;
            String msgcustomer = notice + "/" + customermsg;
            String checksubmitmsg = notice + "/" + checksubmit;
            String msgmoneyofcustomer = notice + "/" + moneyofcustomermsg;
            Vector v = (Vector) request.getAttribute("PDMA");
            Vector vDetail = (Vector) request.getAttribute("Detail");
            int sohdt = 0;
            double tamtinh = 0;
            int maban = 0;
            NumberFormat nf = NumberFormat.getNumberInstance(Locale.FRENCH);

%>
<script type="text/javascript">
    $(function(){
        $('#datepicker1').datepicker($.datepicker.regional['vi']);
        $( "#datepicker1" ).datepicker( "option", "dateFormat","dd/mm/yy");
        $('#datepicker2').datepicker($.datepicker.regional['vi']);
        $( "#datepicker2" ).datepicker( "option", "dateFormat","dd/mm/yy");
    });
</script>
<div class="title">
    <%=orderbillinfo%>
</div>
<div class="content">
    <form name="DMAinfo" id="PDMAinfo" action="" method="Post" target="_blank">
        <div style="float: left; width: 35%; margin-left: 33px; margin-bottom: 15px;">
            <%
                for(int i=0; i<v.size(); i++){
                    Beans.PhieuDatMA p = (Beans.PhieuDatMA) v.elementAt(i);
                    sohdt = p.getSoHDT();
                    tamtinh = p.getTongCong();
                    maban = p.getMaBan();
            %>
            <div style=" float: left; width: 150px; "><%=orderbillid%></div><div style=""><%=p.getSoHDT()%></div><br/>
            <div style=" float: left; width: 150px;"><%=timehistory%></div><div style=""><%=p.getGioVao()%></div><br/>
            <div style=" float: left; width: 150px;"><%=areaname%></div><div style=""><%=PhieuDatMA_Model.LayTenKV(p.getMaBan(), langid)%></div><br/>
            <div style=" float: left; width: 150px;"><%=tablename%></div><div style=""><%=PhieuDatMA_Model.LayTenBan(p.getMaBan())%></div><br/>
            <div style=" float: left; width: 150px;"><%=customerid%></div>
            <input type="textbox" class="text" id="customerid" alt="<%=p.getSoHDT() %>" lang="<%=msgright%>" align="<%=p.getMaBan() %>" name="<%=msgcustomer%>" onchange="UpdatePDMA(this.align, this.value, this.alt, this.lang, this.name)" style=" width: 60px; margin-bottom: 10px; margin-right: 10px; float: left;" value="<%=p.getMaKH()%>" onkeypress="return keypress(event)"><img style=" margin-bottom: 4px; cursor: pointer;" alt="" src="images/addcustomer.png"><br/>
            <div class="cb"></div>
            <div style=" float: left; width: 150px; margin-bottom: 15px;"><%=nameofcustomer%></div>
            <div id="tenkh" style="">
                <%  if(p.getMaKH() == 0){%>
                        <br />
                <%  }
                    else{%>
                        <%=PhieuDatMA_Model.LayKH(p.getMaKH()) %>
                <%  }%>
            </div><br/>
            <div class="cb"></div>
            <div style="float: left; width: 150px;"><%=reduction%></div><div style=""><%=p.getChietKhau() %>   %</div><br/>
            <div style="float: left; width: 150px;"><%=promotion%></div><div><%=nf.format(p.getKMHoaDon())%></div><br/>
            <div style="float: left; width: 150px;"><%=servicecharge%></div><div style=""><%=p.getPhiPhucVu() %>  %</div><br/>
            <div style="float: left; width: 150px;"><%=total%></div><div style=""><%=nf.format(p.getThanhTien()) %>   <%=TienTe_Model.LayKyHieuTT(langid) %></div><br/>
            <div style="float: left; width: 150px;"><%=temptotal%></div><div style=""><%=nf.format(p.getTongCong())  %>    <%=TienTe_Model.LayKyHieuTT(langid) %></div><br/>
            <div style="float: left; width: 150px;"><%=moneyofcustomer%></div>
            <div style=""><input type="textbox" name="tienkhach" onchange="LayTienThoiLai(this.value, this.id, this.lang)" id="<%=tamtinh %>" lang="<%=msgmoneyofcustomer%>" class="text" style=" width: 95px; margin-right: 4px; float: left;" onkeypress="return keypress(event)"><div style="float: left; margin-right: 15px; margin-top: 3px;"><%=TienTe_Model.LayKyHieuTT(langid) %></div><img style=" margin-bottom: 4px; cursor: pointer;" alt="" src="images/addmoney.png"></div><br/>
            <div style="float: left; width: 150px;"><%=moneyback%></div>
            <div id="tienthoilai" style=" width: 100px; float: left;">0</div><%=TienTe_Model.LayKyHieuTT(langid) %><br/>
            <%  }%>
            </div>
        <div style="float: left; width: 61%;">
            <table>
                <thead>
                    <th style="width: 30%;"><%=foodname%></th>
                    <th style="width: 16%;"><%=price%> (<%=TienTe_Model.LayKyHieuTT(langid) %>)</th>
                    <th style="width: 15%;"><%=quantity%></th>
                    <th style="width: 17%;"><%=unit%></th>
                    <th style=""><%=total%> (<%=TienTe_Model.LayKyHieuTT(langid) %>)</th>
                </thead>
                <tbody>
            <%
                for(int j=0; j<vDetail.size(); j++){
                    Beans.CTPhieuDatMA c = (Beans.CTPhieuDatMA) vDetail.elementAt(j);%>
                <tr>
                    <td><%=MonAn_Model.LayTenMA(c.getMaMA(), langid)  %></td>
                    <td><div style=" width: 65px; text-align: right;"><%=nf.format(c.getGia()) %></div></td>
                    <td style="padding-left: 15px;"><%=c.getSoLuong() %></td>
                    <td style=""><%=DonViTinh_Model.LayTenDVT(c.getMaDVT(), langid)  %></td>
                    <td><div style=" width: 70px; text-align: right;"><%=nf.format(c.getThanhTien()) %></div></td>
                </tr>
                <%  }%>
            </tbody>
            </table>
        </div>
            <div class="cb"></div>
            <input type="button" onclick="InPDMA(this.id, this.alt)" id="<%=sohdt %>" alt="<%=maban%>" class="button" value="<%=printorderbill%>" style=" margin-left: 200px; float: left; margin-bottom: 5px;">
            <input type="button" onclick="InHoaDon(this.id, this.alt, this.lang, this.name)" id="<%=maban %>" alt="<%=sohdt %>" name="<%=checksubmitmsg%>" lang="<%=msgright%>" class="button" value="<%=printbill%>" style=" margin-left: 20px; margin-bottom: 5px;">
            
    </form>

</div>

